package com.example.mapper;

import com.example.pojo.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @Select("SELECT * FROM employees LIMIT #{limit} OFFSET #{offset}")
    List<Employee> getEmployees(@Param("limit") int limit, @Param("offset") int offset);

    @Select("SELECT COUNT(*) FROM employees")
    int getTotalEmployees();

    @Select("SELECT * FROM employees WHERE employeeId = #{employeeId}")
    Employee getEmployeeById(@Param("employeeId") String employeeId);

    @Select("SELECT * FROM employees WHERE name LIKE CONCAT('%', #{name}, '%') LIMIT #{limit} OFFSET #{offset}")
    List<Employee> getEmployeeByName(@Param("name") String name, @Param("offset") int offset, @Param("limit") int limit);

    @Select("SELECT COUNT(*) FROM employees WHERE name LIKE CONCAT('%', #{name}, '%')")
    int countEmployeesByName(@Param("name") String name);
}
